<%@page contentType="text/html; charset=UTF-8" trimDirectiveWhitespaces="true" pageEncoding="UTF-8" %>
<html>
<head>
    <%@include file="/WEB-INF/include/include.jsp" %>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15>
                    <form class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/system/user/role_set" method="post">
                        <input type="hidden" name="userId" value="${model.id}">
                        <div class="layui-tab">
                            <%--<ul class="layui-tab-title">
                                <li><a href="${pageContext.request.contextPath}/system/user/list">用户列表</a></li>
                                <li class="layui-this">用户角色设置</li>
                            </ul>--%>
                            <h3 class="page-header">用户角色设置</h3>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-row layui-col-space10">
                                        <div class="layui-col-md4">
                                            <label class="layui-form-label">账号</label>
                                            <div class="layui-input-block">
                                                <input type="text" value="${model.username}" readonly="readonly" autocomplete="off" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <label class="layui-form-label">姓名</label>
                                            <div class="layui-input-block">
                                                <input type="text" value="${model.name}"  readonly="readonly" autocomplete="off" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-col-md4">
                                            <label class="layui-form-label">部门</label>
                                            <div class="layui-input-block">
                                                <input type="text" value="${model.systemDept.name}"  readonly="readonly" autocomplete="off" class="layui-input">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row layui-col-space10">
                                        <div class="layui-col-md12">
                                            <label class="layui-form-label">角色</label>
                                            <div class="layui-input-block">
                                                <input type="checkbox" name="role_id" lay-filter="roleAll" title="全选">
                                                <c:forEach items="${systemRoleList}" var="role">
                                                    <input type="checkbox" name="roleIds" value="${role.id}" title="${role.name}" <c:if test="${role.isCheck == true}">checked</c:if>>
                                                </c:forEach>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" style="padding-left: 10px;">
                            <div class="layui-input-block">
                                <shiro:hasPermission name="user:role_set">
                                    <button class="layui-btn layui-btn-normal" lay-submit >提交</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </shiro:hasPermission>
                                <a href="javascript:history.back();" class="layui-btn layui-btn-primary">返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form','jquery'], function(){
        var form = layui.form,
            $ = layui.$;

        form.on('checkbox(roleAll)', function(data){
            if (data.elem.checked) {
                $("input[type='checkbox']").prop('checked', true);
                form.render('checkbox');
            } else {
                $("input[type='checkbox']").prop('checked', false);
                form.render('checkbox');
            }
        });

    });
</script>
</body>
</html>